package com.mhkj.base.calender.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mhkj.base.calender.entity.WorkCalender;
import com.mhkj.base.calender.service.WorkCalenderService;
import com.mics.core.common.componet.Pagination;
import com.mics.core.common.componet.ResponseMessage;
import com.mics.core.system.base.controller.BaseController;

/**
 * 工作日历
 * @author mics
 * @date 2018年7月2日
 * @version 1.0
 */
@Controller
@RequestMapping("/workCalender")
public class WorkCalenderController extends BaseController<WorkCalender>{
	@Resource
	private WorkCalenderService workCalenderService;
	
	@InitBinder
    protected void init(HttpServletRequest request, ServletRequestDataBinder binder) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        dateFormat.setLenient(false);
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
    }
	 
	@Resource
	public void setWorkCalenderService(WorkCalenderService workCalenderService) {
		super.setBaseService(workCalenderService);
	}
	
	@RequestMapping("/listByPage")
	@ResponseBody
	public Pagination<WorkCalender> listByPage(WorkCalender workCalender,int pageIndex,int pageSize){
		Pagination<WorkCalender> wPagination = workCalenderService.listByPage(workCalender,pageIndex,pageSize);
		return wPagination;
	}
	
	@Override
	@RequestMapping("/save")
	@ResponseBody
	public ResponseMessage save(WorkCalender t) {
		return super.save(t);
	}

	@Override
	@RequestMapping("/edit")
	@ResponseBody
	public ResponseMessage edit(WorkCalender t) {
		return super.edit(t);
	}

	@Override
	@RequestMapping("/del")
	@ResponseBody
	public ResponseMessage del(WorkCalender t) {
		return super.del(t);
	}

	@Override
	@RequestMapping("/info")
	@ResponseBody
	public WorkCalender info(long id) {
		return super.info(id);
	}
	
	
}
